package com.gangwangchina.android.contactlib.model;

import java.util.HashMap;
import java.util.Map;

import com.gangwangchina.android.contactlib.ContactsInterface;


import android.provider.ContactsContract.CommonDataKinds.Nickname;

public class NickName extends DataElement{
	public static final String NAME = Nickname.NAME;
	public static final String CONTENT_ITEM_TYPE = Nickname.CONTENT_ITEM_TYPE;


	public String name;

	/**
	 * Creates a new NickName that is not (yet) present in the database
	 * @param name
	 * @return
	 */
	public static NickName newNotes(String name){
		return new NickName(name);
	}

	/**
	 * Creates an object representation of a NickName that is present in the database
	 * @param pcId
	 * @param name
	 * @return
	 */
	public static NickName recoverNickname(long pcId, String name){
		return new NickName(pcId, name);
	}

	/**
	 * Creates a new NickName
	 * @param pcId the PersonContact the NickName is linked to
	 * @param name
	 */
	private NickName(long pcId, String name){
		this(pcId);
		this.name = name;
	}

	private NickName(String name){
		this(ContactsInterface.NO_ID, name);
	}

	private NickName(long pcId){
		super(pcId, CONTENT_ITEM_TYPE);
	}



//	@Override
	public String toString(){
//		return "{'name':" + this.safeJson(name) + "}";		
		return "";	
	}

	@Override
	public Map<String, Object> getDataColumns() {
		Map<String, Object> datas = new HashMap<String, Object>();
		datas.put(NAME, name);
		return datas;
	}

	@Override
	public boolean setProperty(String key, Object value){
		if(key.equals(NAME)) name = (String) value;
		else return super.setProperty(key, value);
		return true;
	}

	@Override
	public Object getProperty(String key){
		if(key.equals(NAME)) return name;
		return super.getProperty(key);
	}
}